package cn.com.fuhuitong.main.mine.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import cn.com.fuhuitong.app.BaseApplication
import cn.com.fuhuitong.base.BaseViewModel
import cn.com.fuhuitong.http.BaseResponse
import cn.com.fuhuitong.http.HttpResponse
import cn.com.fuhuitong.http.ViewModelSubscribeListener
import cn.com.fuhuitong.main.home.entity.CharityListResponse
import cn.com.fuhuitong.main.home.entity.HomeResponse
import cn.com.fuhuitong.main.mine.entity.*
import cn.com.fuhuitong.main.mine.mode.MineManager
import cn.com.fuhuitong.main.order.mode.OrderManager
import io.reactivex.disposables.Disposable

class ShareViewModel(application: Application) : BaseViewModel(application) {

    private val mineManager: MineManager = MineManager()

    val mineShareDataLiveData = MutableLiveData<HttpResponse<MineShareResponse>>()

    val mineShareCenterDataLiveData = MutableLiveData<HttpResponse<MineShareCenterResponse>>()


    /**
     * 分享配置
     */
    fun share() {
        val listener =
            object : ViewModelSubscribeListener<MineShareResponse>(mineShareDataLiveData) {}
        val shareDisposable: Disposable = mineManager.share(
            BaseApplication.userToken(), listener
        )
        dispose.add(shareDisposable)
    }

    /**
     * 分享中心
     */
    fun distributionCenter() {
        val listener =
            object :
                ViewModelSubscribeListener<MineShareCenterResponse>(mineShareCenterDataLiveData) {}
        val distributionCenterDisposable: Disposable = mineManager.distributionCenter(
            BaseApplication.userToken(), listener
        )
        dispose.add(distributionCenterDisposable)
    }


}